﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// 文件名：ClsOtherStockInDAL.cs
/// 作  者：KIDY
/// 时  间：2006.11.23
/// 说  明：ClsOtherStockInDAL类用于其他入库信息相关处理
/// </summary>
public class ClsOtherStockInDAL
{
    /// <summary>
    /// 数据库连接字符串
    /// </summary>
    private static string strSqlConnectionString = ConfigurationManager.AppSettings["SQLCONNECTIONSTRING"];

    /// <summary>
    /// 获取所有其他入库或其他出库主表信息
    /// </summary>
    /// <param name="Co_ID">公司ID</param>
    /// <param name="User_ID">用户ID</param>
    /// <param name="Ds_ID">数据集ID</param>
    /// <returns>返回采购入库或退货主表信息数据集</returns>
    public DataSet GetOtherStockInMains(string sCurUserId,string sTm_Type)
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GettbhTranM_OtherInto", con);//Pro_GettbhTranM  Pro_AddtbhTranM_OtherInOrOut
        dat.SelectCommand.CommandType = CommandType.StoredProcedure;

        dat.SelectCommand.Parameters.Add("@tm_type", sTm_Type);
        dat.SelectCommand.Parameters.Add("@u_log_id", sCurUserId);

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        return dst;
    }

    /// <summary>
    /// 获取所有其他入库或其他出库信息
    /// <param name="No">ID号</param>
    /// </summary>
    /// <returns>返回采购入库或退货从表信息数据集</returns>
    public DataSet GetOtherStockInChilds(string Td_Type,string Tm_No)
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GettbhTranD", con);
        dat.SelectCommand.CommandType = CommandType.StoredProcedure;

        dat.SelectCommand.Parameters.Add("@tm_no", Tm_No);
        dat.SelectCommand.Parameters.Add("@td_type", Td_Type);

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        return dst;
    }


    /// <summary>
    /// 判断是否可以确认：明细表有记录则可以确认，反之不可以确认
    /// </summary>
    /// <param name="Tm_No">单号</param>
    /// <param name="State"></param>
    /// <param name="Auditor">操作员</param>
    /// <returns>操作是否成功</returns>
    public string WhetherAuditOtherStockIn(string sTm_Type,string sTm_No)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_WhetherAuditTbhTranM", con);        
        com.CommandType = CommandType.StoredProcedure;

        com.Parameters.Add("@tm_type", SqlDbType.NVarChar, 2);
        com.Parameters["@tm_type"].Value = sTm_Type;
        com.Parameters.Add("@tm_no", SqlDbType.NVarChar, 30);
        com.Parameters["@tm_no"].Value = sTm_No;       

        try
        {
            con.Open();
            string strReturn = (string)com.ExecuteScalar();
            return strReturn;
        }
        catch
        {
            return null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 改变单的状态
    /// </summary>
    /// <param name="Tm_No">单号</param>
    /// <param name="State">操作状态(0确认，1取消确认即终止，2作废即作废，3彻底作废)</param>
    /// <param name="Auditor">操作员</param>
    /// <returns>操作是否成功</returns>
    public Boolean AuditOtherStockInState(string Tm_No, string Tm_Type, int State, string Auditor)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_AudittbhTranM_Other", con);//Pro_UpdatetbhTranMState  Pro_AudittbhTranM
        com.CommandType = CommandType.StoredProcedure;
        SqlParameter ParOutPut = new SqlParameter();

        com.Parameters.Add("@dm_no", SqlDbType.NVarChar, 30);
        com.Parameters["@dm_no"].Value = Tm_No;
        com.Parameters.Add("@dm_state", SqlDbType.Int, 4);
        com.Parameters["@dm_state"].Value = State;
        com.Parameters.Add("@auditor", SqlDbType.NVarChar, 60);
        com.Parameters["@auditor"].Value = Auditor;
        com.Parameters.Add("@type", SqlDbType.NVarChar, 2);
        com.Parameters["@type"].Value = Tm_Type;
        ParOutPut = com.Parameters.Add("@relot_no", SqlDbType.NVarChar, 30);
        ParOutPut.Direction = ParameterDirection.Output;
        ParOutPut = com.Parameters.Add("@returnState", SqlDbType.NVarChar, 2);
        ParOutPut.Direction = ParameterDirection.Output;

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    ///// <summary>
    ///// 改变单的状态
    ///// </summary>
    ///// <param name="Tm_No">单号</param>
    ///// <param name="State">操作状态(0确认，1取消确认即终止，2作废即作废，3彻底作废)</param>
    ///// <param name="Auditor">操作员</param>
    ///// <returns>操作是否成功</returns>
    //public string AuditOtherStockInState(string sTm_No, string sTm_Type, int iState, string Auditor)
    //{
    //    SqlConnection con = new SqlConnection(strSqlConnectionString);
    //    SqlCommand com = new SqlCommand("Pro_AudittbhTranM_Other", con);
    //    com.CommandType = CommandType.StoredProcedure;
    //    SqlParameter ParOutPut = new SqlParameter();

    //    com.Parameters.Add("@dm_no", SqlDbType.NVarChar, 30);
    //    com.Parameters["@dm_no"].Value = sTm_No;
    //    com.Parameters.Add("@dm_state", SqlDbType.Int, 4);
    //    com.Parameters["@dm_state"].Value = iState;
    //    com.Parameters.Add("@auditor", SqlDbType.NVarChar, 60);
    //    com.Parameters["@auditor"].Value = Auditor;
    //    com.Parameters.Add("@type", SqlDbType.NVarChar, 2);
    //    com.Parameters["@type"].Value = sTm_Type;
    //    ParOutPut = com.Parameters.Add("@relot_no", SqlDbType.NVarChar, 30);
    //    ParOutPut.Direction = ParameterDirection.Output;
    //    ParOutPut = com.Parameters.Add("@returnState", SqlDbType.NVarChar, 2);
    //    ParOutPut.Direction = ParameterDirection.Output;
    //    try
    //    {
    //        con.Open();
    //        com.ExecuteNonQuery();
    //        string strState = com.Parameters["@returnState"].Value.ToString();
    //        string strReLot_no = com.Parameters["@relot_no"].Value.ToString();
    //        if (strState == "N")
    //        {
    //            return "N" + strReLot_no;
    //        }
    //        else if (strState == "Q")
    //        {
    //            return "Q" + strReLot_no;
    //        }
    //        else
    //        {
    //            return "0";
    //        }

    //        return strReLot_no;
    //    }
    //    catch
    //    {
    //        return "";
    //    }
    //    finally
    //    {
    //        if (con.State == ConnectionState.Open)
    //        {
    //            con.Close();
    //        }
    //    }
    //}

    /// <summary>
    ///修改
    /// </summary>
    /// <param name="Tm_No">单号</param>
    /// <param name="State">操作状态(0确认，1取消确认即终止，2作废即作废，3彻底作废)</param>
    /// <param name="Auditor">操作员</param>
    /// <returns>操作是否成功</returns>
    public Boolean UpdateOtherStockIn(string sTm_type, string sTm_No, DateTime dtInto_date, string sInto_type, string sTm_dept, string sTm_Oper, string sRemark)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_UpdatetbhTranM_M", con);//Pro_UpdatetbhTranMState  Pro_UpdatetbhTranM_OtherOut
        com.CommandType = CommandType.StoredProcedure;

        com.Parameters.Add("@tm_type", SqlDbType.NVarChar, 2);
        com.Parameters["@tm_type"].Value = sTm_type;
        com.Parameters.Add("@tm_no", SqlDbType.NVarChar, 30);
        com.Parameters["@tm_no"].Value = sTm_No;
        com.Parameters.Add("@Into_date", SqlDbType.DateTime, 8);
        com.Parameters["@Into_date"].Value = dtInto_date;
        com.Parameters.Add("@Into_type", SqlDbType.NVarChar, 30);
        com.Parameters["@Into_type"].Value = sInto_type;
        com.Parameters.Add("@Tm_dept", SqlDbType.NVarChar, 30);
        com.Parameters["@Tm_dept"].Value = sTm_dept;
        com.Parameters.Add("@Tm_Oper", SqlDbType.NVarChar, 30);
        com.Parameters["@Tm_Oper"].Value = sTm_Oper;
        com.Parameters.Add("@remark", SqlDbType.NVarChar, 255);
        com.Parameters["@remark"].Value = sRemark;
        com.Parameters.Add("@Cr_id", SqlDbType.NVarChar, 30);//共用同一个SP,此SP中有这个参数
        com.Parameters["@Cr_id"].Value = "";

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 修改 其他出库 
    /// </summary>
    /// <param name="Tm_No">单号</param>
    /// <param name="State">操作状态(0确认，1取消确认即终止，2作废即作废，3彻底作废)</param>
    /// <param name="Auditor">操作员</param>
    /// <returns>操作是否成功</returns>
    public Boolean UpdateOtherStockOut(string sTm_type, string sTm_No, DateTime dtInto_date, string sReason_type, 
        string sWh_id, string sTm_Oper, string sRemark)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_UpdatetbhTranM_OtherOut", con);//Pro_UpdatetbhTranMState  Pro_UpdatetbhTranM_M
        com.CommandType = CommandType.StoredProcedure;

        com.Parameters.Add("@tm_type", SqlDbType.NVarChar, 2);
        com.Parameters["@tm_type"].Value = sTm_type;
        com.Parameters.Add("@tm_no", SqlDbType.NVarChar, 30);
        com.Parameters["@tm_no"].Value = sTm_No;
        com.Parameters.Add("@Into_date", SqlDbType.DateTime, 8);
        com.Parameters["@Into_date"].Value = dtInto_date;
        com.Parameters.Add("@Reason_type", SqlDbType.NVarChar, 30);
        com.Parameters["@Reason_type"].Value = sReason_type;
        com.Parameters.Add("@Wh_id", SqlDbType.NVarChar, 30);
        com.Parameters["@Wh_id"].Value = sWh_id;
        com.Parameters.Add("@Tm_Oper", SqlDbType.NVarChar, 30);
        com.Parameters["@Tm_Oper"].Value = sTm_Oper;
        com.Parameters.Add("@remark", SqlDbType.NVarChar, 255);
        com.Parameters["@remark"].Value = sRemark;

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }


    /// <summary>
    /// 作废其他入库主表信息
    /// </summary>
    /// <param>其他入库编号</param>
    /// <param name="Is_Visible">作废状态1为临时作废，－1为彻底作废</param>
    /// <returns>返回作废是否成功</returns>
    public Boolean DeleteOtherStockIn(string sTm_type,string sTm_no, int iIs_Visible)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_DeleteOtherStockInM", con);
        com.CommandType = CommandType.StoredProcedure;

        com.Parameters.Add("@tm_type", SqlDbType.NVarChar, 2);
        com.Parameters["@tm_type"].Value = sTm_type;
        com.Parameters.Add("@tm_no", SqlDbType.NVarChar, 20);
        com.Parameters["@tm_no"].Value = sTm_no;
        com.Parameters.Add("@Is_Visible", SqlDbType.Int, 1);
        com.Parameters["@Is_Visible"].Value = iIs_Visible;

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 作废其他出、入库明细
    /// </summary>
    /// <param name="Tm_No"></param>
    /// <param name="Td_Type"></param>
    /// <param name="Im_No"></param>
    /// <param name="State"></param>
    /// <returns></returns>string sLot_no,
    public Boolean DeleteChildOtherStockIn(int iId,string sTm_Type, string sTm_No, string sIm_No, int iCommandName)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_DeletetbhTranD", con);
        com.CommandType = CommandType.StoredProcedure;

        com.Parameters.Add("@id", SqlDbType.Int);
        com.Parameters["@id"].Value = iId;
        com.Parameters.Add("@tm_type", SqlDbType.NVarChar, 2);
        com.Parameters["@tm_type"].Value = sTm_Type;
        com.Parameters.Add("@tm_no", SqlDbType.NVarChar,30);
        com.Parameters["@tm_no"].Value = sTm_No;        
        com.Parameters.Add("@im_no", SqlDbType.NVarChar,30);
        com.Parameters["@im_no"].Value = sIm_No;
        com.Parameters.Add("@CommandName", SqlDbType.Int, 2);
        com.Parameters["@CommandName"].Value = iCommandName;

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 增加其他入库信息
    /// </summary>
    /// <param>其他入库编号</param>
    /// <param>......</param>
    /// <returns>返回修改是否成功</returns>
///strTm_no, dtInto_date, strInto_type,strTm_dept, strTm_Oper, strRemark
    public Boolean AddOtherStockIn(string sTm_type, string sTm_No, DateTime dTm_date, string sReason_type, string sWh_id, string sTm_Oper, string sRemark)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_AddtbhTranM_OtherInOrOut", con);//Pro_AddtbhTranM  Pro_AddtbhTranM_M
        com.CommandType = CommandType.StoredProcedure;

        com.Parameters.Add("@tm_type", SqlDbType.NVarChar, 2);
        com.Parameters["@tm_type"].Value = sTm_type;
        com.Parameters.Add("@tm_no", SqlDbType.NVarChar, 30);
        com.Parameters["@tm_no"].Value = sTm_No;
        com.Parameters.Add("@tm_date", SqlDbType.DateTime, 8);
        com.Parameters["@tm_date"].Value = dTm_date;
        com.Parameters.Add("@Reason_type", SqlDbType.NVarChar, 30);
        com.Parameters["@Reason_type"].Value = sReason_type;
        com.Parameters.Add("@Tm_depot", SqlDbType.NVarChar, 30);
        com.Parameters["@Tm_depot"].Value = sWh_id;
        com.Parameters.Add("@Tm_Oper", SqlDbType.NVarChar, 30);
        com.Parameters["@Tm_Oper"].Value = sTm_Oper;
        com.Parameters.Add("@remark", SqlDbType.NVarChar, 255);
        com.Parameters["@remark"].Value = sRemark;

        try
        {
            con.Open();
            com.ExecuteNonQuery();
            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 增加其他入库明细信息
    /// </summary>
    /// <param>其他入库编号</param>
    /// <param>......</param>
    /// <returns>返回修改是否成功</returns>
    public Boolean AddChildOtherStockIn(string Td_Type, string Tm_No, string Im_No, string sDepot_id, decimal dQty, decimal dPrice,
        String sBatchNo, string sIdentifyNo, string Remark)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_AddtbhTranD", con);

        com.CommandType = CommandType.StoredProcedure;

        com.Parameters.Add("@td_type", SqlDbType.NVarChar, 2);
        com.Parameters["@td_type"].Value = Td_Type;
        com.Parameters.Add("@tm_no", SqlDbType.NVarChar, 30);
        com.Parameters["@tm_no"].Value = Tm_No;
        com.Parameters.Add("@im_no", SqlDbType.NVarChar, 30);
        com.Parameters["@im_no"].Value = Im_No;
        com.Parameters.Add("@depot_id", SqlDbType.NVarChar, 30);
        com.Parameters["@depot_id"].Value = sDepot_id;
        com.Parameters.Add("@qty", SqlDbType.Decimal, 28);
        com.Parameters["@qty"].Value = dQty;
        com.Parameters.Add("@remark", SqlDbType.NVarChar, 255);
        com.Parameters["@remark"].Value = Remark;
        com.Parameters.Add("@lot_no", SqlDbType.NVarChar, 30);
        com.Parameters["@lot_no"].Value = sBatchNo;
        com.Parameters.Add("@oo_no", SqlDbType.NVarChar, 30);
        com.Parameters["@oo_no"].Value = sIdentifyNo;
        com.Parameters.Add("@Price", SqlDbType.Decimal, 28);
        com.Parameters["@Price"].Value = dPrice;

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 修改其他入库明细信息
    /// </summary>
    /// <param>其他入库编号</param>
    /// <param>......</param>
    /// <returns>返回修改是否成功</returns>
    public Boolean UpdateChildOtherStockIn(int iId,string Td_Type, string Tm_No, string Im_No, string sDepot_id, decimal dQty,
        String sBatchNo, string sIdentifyNo, string Remark)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_UpdatetbhTranD", con);
        com.CommandType = CommandType.StoredProcedure;

        com.Parameters.Add("@id", SqlDbType.Int);
        com.Parameters["@id"].Value = iId;
        com.Parameters.Add("@td_type", SqlDbType.NVarChar, 2);
        com.Parameters["@td_type"].Value = Td_Type;
        com.Parameters.Add("@tm_no", SqlDbType.NVarChar, 30);
        com.Parameters["@tm_no"].Value = Tm_No;
        com.Parameters.Add("@im_no", SqlDbType.NVarChar, 30);
        com.Parameters["@im_no"].Value = Im_No;
        com.Parameters.Add("@depot_id", SqlDbType.NVarChar, 30);
        com.Parameters["@depot_id"].Value = sDepot_id;
        com.Parameters.Add("@qty", SqlDbType.Decimal, 28);
        com.Parameters["@qty"].Value = dQty;
        com.Parameters.Add("@remark", SqlDbType.NVarChar, 255);
        com.Parameters["@remark"].Value = Remark;
        com.Parameters.Add("@Price", SqlDbType.Decimal, 28);//共用同一个SP,此SP中有这个参数
        com.Parameters["@Price"].Value = 0;
        com.Parameters.Add("@lot_no", SqlDbType.NVarChar, 30);
        com.Parameters["@lot_no"].Value = sBatchNo;
        com.Parameters.Add("@oo_no", SqlDbType.NVarChar, 30);
        com.Parameters["@oo_no"].Value = sIdentifyNo;

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    public Boolean AddOrUpdateOtherStockIn(string Td_Type,string Tm_No, string Im_No, string Remark)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_AddtbhTranD", con);

        com.CommandType = CommandType.StoredProcedure;

        com.Parameters.Add("@td_type", SqlDbType.NVarChar, 2);
        com.Parameters["@td_type"].Value = Td_Type;
        com.Parameters.Add("@tm_no", SqlDbType.NVarChar, 30);
        com.Parameters["@tm_no"].Value = Tm_No;
        com.Parameters.Add("@im_no", SqlDbType.NVarChar, 30);
        com.Parameters["@im_no"].Value = Im_No;
        com.Parameters.Add("@remark", SqlDbType.NVarChar, 255);
        com.Parameters["@remark"].Value = Remark;
        //com.Parameters.Add("@operate_type", SqlDbType.Int);
        //com.Parameters["@operate_type"].Value = OperateType;

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 检查 其他入库 是否可以取消确认：依据（库存中是否有相应记录，并且出库数量小于或等于该商品期末数量）
    /// <returns>CREATE BY KIDY ON 20061208</returns>
    /// </summary>
    public String CheckWhetherAudtit(string sTm_No, string sTm_Type, int iState, string Auditor)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_AudittbhTranM_Other", con);
        com.CommandType = CommandType.StoredProcedure;
        SqlParameter ParOutPut = new SqlParameter();

        com.Parameters.Add("@dm_no", SqlDbType.NVarChar, 30);
        com.Parameters["@dm_no"].Value = sTm_No;
        com.Parameters.Add("@dm_state", SqlDbType.Int, 4);
        com.Parameters["@dm_state"].Value = iState;
        com.Parameters.Add("@auditor", SqlDbType.NVarChar, 60);
        com.Parameters["@auditor"].Value = Auditor;
        com.Parameters.Add("@type", SqlDbType.NVarChar, 2);
        com.Parameters["@type"].Value = sTm_Type;
        ParOutPut = com.Parameters.Add("@reIm_no", SqlDbType.VarChar, 30);
        ParOutPut.Direction = ParameterDirection.Output;
        ParOutPut = com.Parameters.Add("@relot_no", SqlDbType.NVarChar, 30);
        ParOutPut.Direction = ParameterDirection.Output;
        ParOutPut = com.Parameters.Add("@returnState", SqlDbType.NVarChar, 2);
        ParOutPut.Direction = ParameterDirection.Output;
        try
        {
            con.Open();
            com.ExecuteNonQuery();
            string strState = com.Parameters["@returnState"].Value.ToString();//返回状态（N:未入库;Q:库存不足）
            string strReIm_no = com.Parameters["@reIm_no"].Value.ToString();//返回的商品号
            string strReLot_no = com.Parameters["@relot_no"].Value.ToString();//返回的批号
            if (strState == "N")
            {
                return "N" +"|"+strReIm_no+"|"+ strReLot_no;
            }
            else if (strState == "Q")
            {
                return "Q" + "|" + strReIm_no + "|" + strReLot_no;
            }
            else
            {
                return "0";
            }
        }
        catch
        {
            return "";
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 根据查询状态获取所有主表信息
    /// </summary>CREATE BY KIDY ON 20070106
    /// <param name="Type">类型</param>
    /// <returns>返回主表信息数据集</returns>
    public DataSet GetOrderInformationByStatu(string sUserId,string sTable, string sType, int iQueryType)
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GetOrderByOtherOI", con);
        dat.SelectCommand.CommandType = CommandType.StoredProcedure;

        dat.SelectCommand.Parameters.Add("@u_log_id", SqlDbType.VarChar, 30);
        dat.SelectCommand.Parameters["@u_log_id"].Value = sUserId;
        dat.SelectCommand.Parameters.Add("@table", SqlDbType.VarChar, 30);
        dat.SelectCommand.Parameters["@table"].Value = sTable;
        dat.SelectCommand.Parameters.Add("@type", SqlDbType.NVarChar, 2);
        dat.SelectCommand.Parameters["@type"].Value = sType;
        dat.SelectCommand.Parameters.Add("@queryType", SqlDbType.Int, 2);
        dat.SelectCommand.Parameters["@queryType"].Value = iQueryType;

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        return dst;
    }
}
